package 时间;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class 时刻 {
    public static void main(String[] args) {

        Instant instant = Instant.now(); //取到皮秒
        System.out.println(instant);

        ZonedDateTime time1 = ZonedDateTime.now();
        System.out.println(time1);

        time1.withYear(2050);//产生新对象
        System.out.println(time1);
        System.out.println(time1.withYear(2060));

        //时间对象
        ZonedDateTime zonetime = Instant.now().atZone(ZoneId.of("Asia/Shanghai"));
        //时间格式器
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy_MM_dd HH_mm_ss EE a");
        System.out.println(dtf.format(zonetime));


    }
}
